(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

sort(nil) → nil
sort(cons(x, y)) → insert(x, sort(y))
insert(x, nil) → cons(x, nil)
insert(x, cons(v, w)) → choose(x, cons(v, w), x, v)
choose(x, cons(v, w), y, 0) → cons(x, cons(v, w))
choose(x, cons(v, w), 0, s(z)) → cons(v, insert(x, w))
choose(x, cons(v, w), s(y), s(z)) → choose(x, cons(v, w), y, z)

Rewrite Strategy: INNERMOST

(1) CpxTrsToCdtProof (BOTH BOUNDS(ID, ID) transformation)

Converted Cpx (relative) TRS to CDT

(2) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort(nil) → nil
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
Tuples:

SORT(nil) → c
SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, nil) → c2
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), z3, 0) → c4
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
S tuples:

SORT(nil) → c
SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, nil) → c2
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), z3, 0) → c4
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
K tuples:none
Defined Rule Symbols:

sort, insert, choose

Defined Pair Symbols:

SORT, INSERT, CHOOSE

Compound Symbols:

c, c1, c2, c3, c4, c5, c6

(3) CdtLeafRemovalProof (BOTH BOUNDS(ID, ID) transformation)

Removed 3 trailing nodes:

INSERT(z0, nil) → c2
CHOOSE(z0, cons(z1, z2), z3, 0) → c4
SORT(nil) → c

(4) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort(nil) → nil
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
S tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
K tuples:none
Defined Rule Symbols:

sort, insert, choose

Defined Pair Symbols:

SORT, INSERT, CHOOSE

Compound Symbols:

c1, c3, c5, c6

(5) CdtRuleRemovalProof (UPPER BOUND(ADD(n^1)) transformation)

Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
We considered the (Usable) Rules:none
And the Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
The order we found is given by the following interpretation:
Polynomial interpretation :

POL(0) = 0   
POL(CHOOSE(x1, x2, x3, x4)) = 0   
POL(INSERT(x1, x2)) = 0   
POL(SORT(x1)) = x1   
POL(c1(x1, x2)) = x1 + x2   
POL(c3(x1)) = x1   
POL(c5(x1)) = x1   
POL(c6(x1)) = x1   
POL(choose(x1, x2, x3, x4)) = 0   
POL(cons(x1, x2)) = [1] + x2   
POL(insert(x1, x2)) = 0   
POL(nil) = 0   
POL(s(x1)) = 0   
POL(sort(x1)) = 0   

(6) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort(nil) → nil
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
S tuples:

INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
K tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
Defined Rule Symbols:

sort, insert, choose

Defined Pair Symbols:

SORT, INSERT, CHOOSE

Compound Symbols:

c1, c3, c5, c6

(7) CdtRuleRemovalProof (UPPER BOUND(ADD(n^2)) transformation)

Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.

CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
We considered the (Usable) Rules:

choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
sort(nil) → nil
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
And the Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
The order we found is given by the following interpretation:
Polynomial interpretation :

POL(0) = 0   
POL(CHOOSE(x1, x2, x3, x4)) = x3 + [2]x1·x2   
POL(INSERT(x1, x2)) = x1 + [2]x1·x2   
POL(SORT(x1)) = [2]x12   
POL(c1(x1, x2)) = x1 + x2   
POL(c3(x1)) = x1   
POL(c5(x1)) = x1   
POL(c6(x1)) = x1   
POL(choose(x1, x2, x3, x4)) = [2] + x1 + x2   
POL(cons(x1, x2)) = [1] + x1 + x2   
POL(insert(x1, x2)) = [2] + x1 + x2   
POL(nil) = 0   
POL(s(x1)) = [2] + x1   
POL(sort(x1)) = [2]x1   

(8) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort(nil) → nil
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
S tuples:

INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
K tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
Defined Rule Symbols:

sort, insert, choose

Defined Pair Symbols:

SORT, INSERT, CHOOSE

Compound Symbols:

c1, c3, c5, c6

(9) CdtRuleRemovalProof (UPPER BOUND(ADD(n^2)) transformation)

Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.

CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
We considered the (Usable) Rules:

choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
sort(nil) → nil
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
And the Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
The order we found is given by the following interpretation:
Polynomial interpretation :

POL(0) = [1]   
POL(CHOOSE(x1, x2, x3, x4)) = [2] + x3 + x1·x2   
POL(INSERT(x1, x2)) = [2] + x1 + x1·x2   
POL(SORT(x1)) = x1 + x12   
POL(c1(x1, x2)) = x1 + x2   
POL(c3(x1)) = x1   
POL(c5(x1)) = x1   
POL(c6(x1)) = x1   
POL(choose(x1, x2, x3, x4)) = [1] + [2]x1 + x2   
POL(cons(x1, x2)) = [1] + x1 + x2   
POL(insert(x1, x2)) = [1] + [2]x1 + x2   
POL(nil) = 0   
POL(s(x1)) = x1   
POL(sort(x1)) = [2]x1   

(10) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort(nil) → nil
sort(cons(z0, z1)) → insert(z0, sort(z1))
insert(z0, nil) → cons(z0, nil)
insert(z0, cons(z1, z2)) → choose(z0, cons(z1, z2), z0, z1)
choose(z0, cons(z1, z2), z3, 0) → cons(z0, cons(z1, z2))
choose(z0, cons(z1, z2), 0, s(z3)) → cons(z1, insert(z0, z2))
choose(z0, cons(z1, z2), s(z3), s(z4)) → choose(z0, cons(z1, z2), z3, z4)
Tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
S tuples:

INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
K tuples:

SORT(cons(z0, z1)) → c1(INSERT(z0, sort(z1)), SORT(z1))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
Defined Rule Symbols:

sort, insert, choose

Defined Pair Symbols:

SORT, INSERT, CHOOSE

Compound Symbols:

c1, c3, c5, c6

(11) CdtKnowledgeProof (EQUIVALENT transformation)

The following tuples could be moved from S to K by knowledge propagation:

INSERT(z0, cons(z1, z2)) → c3(CHOOSE(z0, cons(z1, z2), z0, z1))
CHOOSE(z0, cons(z1, z2), 0, s(z3)) → c5(INSERT(z0, z2))
CHOOSE(z0, cons(z1, z2), s(z3), s(z4)) → c6(CHOOSE(z0, cons(z1, z2), z3, z4))
Now S is empty

(12) BOUNDS(1, 1)